#include "StdAfx.h"
#include "User.h"

CUser::CUser(void)
{
}

CUser::~CUser()
{
	m_mapUser.erase(m_mapUser.begin(), m_mapUser.end());
}

int CUser::AddUser(_userinfo *ui)
{
	m_mapUser.insert(UserType(ui->strName, ui));
	return 0;
}

int CUser::DeleteUser(string name)
{
	CMLog::Plog("CUser::DeleteUser, name:%s", name.c_str());

	std::map<string, _userinfo*>::iterator it;
	it = m_mapUser.find(name);
	m_mapUser.erase(it);
	return 1;
}


int CUser::SearchUser(string name)
{
	CMLog::Plog("CUser::SearchUser, name:%s", name.c_str());
	if (m_mapUser.size() < 1)
		return 0;

	std::map<string, _userinfo*>::iterator it;
	it = m_mapUser.find(name);
	_userinfo *ui = it->second;
	return ui->_uid;
}

int CUser::GetUserAccount()
{
	return m_mapUser.size();
}

void CUser::SetSelfName(string me)
{
	m_uiMe.strName = me;
}

void CUser::GetSelfInfo(_userinfo *me)
{
	me = &m_uiMe;
}
